package com.six.goods.controller;

import com.six.core.entity.Brand;
import com.six.core.vo.Result;
import com.six.goods.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: whj
 * @Version 1.0
 * @Date: 2023/2/27  15:39
 */

@Component
@RequestMapping("/goods/brand")
public class BrandController {
    @Autowired
    private BrandService brandService;

    //分页
    @PostMapping("/selebrand")
    @ResponseBody
    public Result selebrand(@RequestParam(defaultValue = "1")Integer currentPage, @RequestParam(defaultValue = "5") Integer pageSize,@RequestBody Brand brand){
        return brandService.seleAllBrand(currentPage,pageSize,brand);
    }
    //修改品牌
    @PutMapping("/upBrand")
    @ResponseBody
    public Result upBrand(@RequestBody Brand brand){
        return brandService.updateBrand(brand);
    }
    //增加品牌
    @PostMapping("/insBrand")
    @ResponseBody
    public Result insBrand(@RequestBody Brand brand){
        return brandService.insertBrand(brand);
    }
    //删除品牌
    @DeleteMapping("/deleteBrand/{id}")
    @ResponseBody
    public Result deleteBrand(@PathVariable Integer id){
        return brandService.deleteBrand(id);
    }
    //查询品牌
    @PostMapping("/selectAllBrand")
    @ResponseBody
    public Result selectAllBrand(){
        return brandService.selectAllBrand();
    }

    @PostMapping("/seleBybrandname")
    @ResponseBody
    public Brand seleBybrandname(@RequestBody Brand brand){
        return brandService.seleBybrandname(brand);
    }

}
